<template>
	<view class="box">
		<!-- 商品轮播图 -->
		<view class="swiper">
			<swiper :indicator-dots="true" :autoplay="true" :interval="3000" indicator-active-color="#fff"
				indicator-color="rgba(255,255,255,.5)" :duration="1000">
				<swiper-item v-for="(item,index) of banner_list" :key="index" @click="prevImg(item.img,banner_list)">
					<view class="swiper-item">
						<image :src="item.img" mode="aspectFit"></image>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<!-- 商品信息 -->
		<view class="msg" v-if="type!=1">
			<view class="name f30 bold">
				饱满海南大香蕉 约450-500g/份，图片仅供参考以实物为准
			</view>
			<!-- 普通价 -->
			<view class="price fw-bt">
				<view class="price-l f-w">
					<view class="red">￥<text class="f36 bold">10.9</text></view>
					<view class="oprice">￥18.0</view>
				</view>
			</view>
		</view>
		<!-- 兑换说明：仅可兑换商品券相对应的商品 -->
		<view class="desc">
			兑换说明：仅可兑换商品券相对应的商品
		</view>
		<!-- 商品详情 -->
		<view class="detail">
			<view class="title f28 bold">商品详情</view>
			<!-- 富文本 -->
			<view class="rich"></view>
		</view>
		<!-- 立即兑换 -->
		<view class="btn" @click="goDuihuan">立即兑换</view>
	</view>
</template>

<script>
	import cart from '@/components/cart.vue'
	export default {
		components: {
			cart
		},
		data() {
			return {
				id: '', //商品id
				isSc: false, //
				num: 10, //
				date:'',//倒计时时间
				banner_list: [{
						img: 'https://jw.xzsw2021.com/static/index/tu_18@2x.png'
					},
					{
						img: 'https://jw.xzsw2021.com/static/client/icon_60@2x.png'
					},
					{
						img: 'https://jw.xzsw2021.com/static/client/icon_103@2x.png'
					}
				], //
				type:'',//商品类型 1.秒杀类 3.兑换类
			}
		},
		onShareAppMessage(options) {
			console.log(options);
			let that = this;
			let shareObj = {
				title: '分享给好友',
				imageUrl: '',
				path: 'pages/client/shop/shop-detail/shop-detail?shop_id=1' + '&agent_id=' + 2,
				success: function(res) {
					// 转发成功之后的回调
					if (res.errMsg == 'shareAppMessage:ok') {}
				},
				fail: function() {
					// 转发失败之后的回调
					if (res.errMsg == 'shareAppMessage:fail cancel') {
						// 用户取消转发
					} else if (res.errMsg == 'shareAppMessage:fail') {
						// 转发失败，其中 detail message 为详细失败信息
					}
				},

			}
			　// 来自页面内的按钮的转发
			　　if( options.from == 'button' ){
			　　　　var eData = options.target.dataset;
			　　　　console.log( eData.name );     // shareBtn
			　　　　// 此处可以修改 shareObj 中的内容
			　　　　shareObj.imageUrl = that.path;
			　　}
			return shareObj;
		},
		onLoad(options) {
			this.id = options.id ? options.id : '';
			if(options.type){
				console.log(options);
				this.type=options.type
				console.log('类型',this.type);
			}
		},
		mounted() {
			
		},
		methods: {
			// 大图预览
			prevImg(item, arr) {
				var a1 = [];
				arr.map(item => {
					a1.push(item.img)
				})
				console.log(a1);
				uni.previewImage({
					current: item,
					urls: a1,
					success() {

					},
					fail(err) {
						console.log(err);
					}
				})
			},
			// 兑换
			goDuihuan(){
				// this.$showToast('只能兑换商品券规定的商品')
				this.$showToast('兑换成功')
				setTimeout(()=>{
					uni.navigateTo({
						url:'/pages/state/success/success?type=3'
					})
				},1000)
				
			}
		}
	}
</script>
<style>
	page {
		background-color: #f5f5f5;
	}
</style>

<style lang="scss" scoped>
	.box {
		padding-bottom: 160rpx;
		.myimg {
			width: 100%;
			height: 100%;
		}

		.red {
			color: #F83535;
		}

		.swiper {
			width: 750rpx;
			height: 560rpx;

			swiper {
				width: 750rpx;
				height: 560rpx;

				.swiper-item {
					width: 750rpx;
					height: 560rpx;

					image {
						width: 100%;
						height: 100%;
					}
				}
			}

		}
		.msg {
			padding: 34rpx 30rpx 24rpx;
			background-color: #fff;
			.two {
				margin-top: 15rpx;

				.two1 {
					width: 600rpx;
					color: #666;
					font-size: 22rpx;
				}

				.two2 {
					.sc {
						width: 33rpx;
						height: 30rpx;

						image {
							@extend .myimg;
						}
					}

					.fx {
						margin-left: 20rpx;
						width: 29rpx;
						height: 30rpx;

						image {
							@extend .myimg;
						}
					}
				}
				.two3{
					height: 50rpx;
					input{
						width: 60rpx;
						margin: 0 10rpx;
						font-weight: 600;
						font-size: 28rpx;
						text-align: center;
					}
					.cart1-jian,.cart1-add{
						width: 40rpx;
						height: 40rpx;
						image{
							@extend .myimg;
						}
					}
				}
			}

			.price {
				margin-top: 20rpx;
				font-size: 24rpx;
				color: #999;

				.oprice {
					margin-top: 8rpx;
					margin-left: 10rpx;
					text-decoration: line-through;
				}

				.price-r {
					margin-top: 25rpx;

					.price-r1 {
						font-size: 24rpx;
						color: #109C7A;
					}

					.price-r2 {
						margin-left: 40rpx;
						width: 150rpx;
						height: 50rpx;
						line-height: 50rpx;
						text-align: center;
						font-size: 24rpx;
						font-weight: bold;
						color: #FFFFFF;
						background: linear-gradient(64deg, #2BCCA5, #22B591);
						border-radius: 10rpx;
					}
				}
			}
		}
		.desc{
			margin-top: 20rpx;
			padding: 30rpx;
			font-size: 26rpx;
			background-color: #fff;
		}
		.detail {
			margin-top: 30rpx;
			padding: 30rpx 30rpx;
			background-color: #fff;
			.rich {
				margin-top: 24rpx;
				// min-height: 100rpx;
				image {
					width: 100%;
					height: 100%;
				}
			}
		}
		.btn{
			position: fixed;
			bottom: 0;
			left: 0;
			width: 750rpx;
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
			color: #fff;
			font-size: 32rpx;
			background: linear-gradient(64deg, #2BCCA5, #22B591);
		}
	}
</style>
